﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace BeniBastanYaratWinFormProject
{
    public partial class StokTanılama : Form
    {
        SqlDataAdapter adp;
        DataSet ds;
        SqlConnection cnn = new SqlConnection("Server=mssql.mustafadindar.com;Database=BeniBastanYaratDB;User Id=Admin3207;Password=Y1234567?");
        public StokTanılama()
        {
            InitializeComponent();
            
             adp = new SqlDataAdapter("Select * from Urunler,Kategoriler where Urunler.KategoriID = Kategoriler.KategoriID", cnn);
         
             ds = new DataSet();
            adp.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0]; 
            
            

        }

        private void btnGuncelle_Click(object sender, EventArgs e)
        {
            adp.UpdateCommand = new SqlCommand("UPDATE Urunler SET UrunAdi = @UrunAdi, UrunStok = @UrunStok where UrunID = @UrunID",cnn);
            SqlParameter prm = new SqlParameter("@UrunID", SqlDbType.Int, 9999, "UrunID");
            SqlParameter prm3 = new SqlParameter("@UrunAdi", SqlDbType.NVarChar,150, "UrunAdi");
            SqlParameter prm2 = new SqlParameter("@UrunStok", SqlDbType.Int, 9999, "UrunStok");
            
            adp.UpdateCommand.Parameters.Add(prm);
            adp.UpdateCommand.Parameters.Add(prm2);
   adp.UpdateCommand.Parameters.Add(prm3);
            
            adp.Update(ds.Tables[0]);
            MessageBox.Show("Güncelleme yapılmıştır.");
        }
    }
}
